//
//  HzlTitleButton.m
//  HZLWeiBo
//
//  Created by SDMac on 15/5/25.
//  Copyright (c) 2015年 SDMac. All rights reserved.
//

#import "HZLTitleButton.h"
#import "UIView+Hzl.h"

@implementation HZLTitleButton

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        // 文字颜色
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[self setTitleColor:[UIColor colorWithRed:235/255.0 green:107/255.0 blue:37/255.0 alpha:1.0] forState:UIControlStateHighlighted];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:11];
        
        // 高亮时不要让imageView变灰色
        self.adjustsImageWhenHighlighted = NO;
        self.imageView.contentMode = UIViewContentModeCenter;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        
//        self.titleLabel.backgroundColor = [UIColor blueColor];
//        self.imageView.backgroundColor = [UIColor yellowColor];
    }
    
    return self;
}
// 设置按钮里imageView的fram
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat imageY = 0;
    CGFloat imageW = self.width;
    CGFloat imageX = 0;
    CGFloat imageH = self.height - 20;
    
    //NSLog(@"图像:%1.0f,%1.0f,%1.0f,%1.0f",imageX, imageY, imageW, imageH);
    
    return CGRectMake(imageX, imageY, imageW, imageH);
}
// 设置按钮里titleLable的fram
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat titleY = self.height - 20;
    CGFloat titleX = 0;
    CGFloat titleW = self.width;
    CGFloat titleH = 15;
    //NSLog(@"字符:%1.0f,%1.0f,%1.0f,%1.0f",titleX, titleY, titleW, titleH);
    
    return CGRectMake(titleX, titleY, titleW, titleH);
}

@end
